var main = angular.module('main');

main.controller('projectsCtrl', ['$scope', 'http', '$state', '$stateParams', function($scope, http, $state, $stateParams) {
    http.get('/project/list').then(function(data) {
        $scope.projects = data.data;

    });

    $scope.type = $stateParams.type;

    $scope.allFilter = function(item) {
        return true;
    };
    $scope.originalFilter = function(item) {
        if (item.role === "0")
            return true;
        return false;
    };
    $scope.developinglFilter = function(item) {
        if (item.role === "0" || item.role === "1")
            return true;
        return false;
    };
    $scope.observingFilter = function(item) {
        if (item.role === "2")
            return true;
        return false;
    };

    if ($scope.type === 'allProject')
        $scope.typeFilter = $scope.allFilter;
    if ($scope.type === 'originalProject')
        $scope.typeFilter = $scope.originalFilter;
    if ($scope.type === 'developingProject')
        $scope.typeFilter = $scope.developinglFilter;
    if ($scope.type === 'observingProject')
        $scope.typeFilter = $scope.observingFilter;
}]);